package cyx.example.ddd.domain.order.model.entity;

import cyx.example.ddd.domain.order.model.valueobject.Money;
import cyx.example.ddd.domain.shared.Entity;
import lombok.Getter;

/**
 * 订单项实体
 */
@Getter
public class OrderItem extends Entity<Long> {
    private final String productId;
    private final String productName;
    private final Money unitPrice;
    private final int quantity;
    private final Money totalPrice;

    public OrderItem(String productId, String productName, Money unitPrice, int quantity) {
        this.productId = productId;
        this.productName = productName;
        this.unitPrice = unitPrice;
        this.quantity = quantity;
        this.totalPrice = unitPrice.multiply(quantity);
    }
}